<script setup lang="ts">
import type {FormInstance, FormRules} from "element-plus";
import {submit} from "dom7";

definePageMeta({
  title:'域名转入',
  layout:'admin',
})
const formRef=ref<FormInstance>()
const rules=reactive<FormRules>({
  domain:[
    {required:true,message:'请输入域名',trigger:'blur'}
  ],
  authcode:[
    {required:true,message:'请输入授权码',trigger:'blur'}
  ]
})
const form=reactive({
  domain:'',//hp72.com
  authcode:'',//Y*GM0Z45YmpJT!k6
})
const submit=()=>{
  formRef.value?.validate(async (isValid, invalidFields)=>{
    if(isValid){
    const {code,message}=await usePost('/west/onlyTransferDomain',form)
      if(code==200){
          ElMessage.success('转入成功');
          formRef.value?.resetFields();
          formRef.value?.clearValidate();
          navigateTo('/admin/domain')
        }else{
        ElMessage.error(message);
        }
    }else {
      showFieldsError(invalidFields)
    }
  })
}
</script>

<template>
<el-card>
  <el-form :model="form" :rules="rules" ref="formRef" label-width="120" class="w-[500px] mx-auto">
    <el-form-item label="域名" prop="domain">
      <el-input v-model="form.domain" placeholder="请输入域名" clearable></el-input>
    </el-form-item>
    <el-form-item label="授权码" prop="authcode">
      <el-input v-model="form.authcode" placeholder="请输入授权码" clearable></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">提交</el-button>
    </el-form-item>
  </el-form>
</el-card>
</template>

<style scoped lang="scss">

</style>